﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GEMINI_OP10
{
    public partial class FormManMode : Form
    {
        public FormManMode()
        {
            InitializeComponent();
        }
        //静音按钮
        private void button2_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX0.2", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.2"));
        }
        //相机屏蔽按钮
        private void button12_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX0.5", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.5"));
        }
        //扫码屏蔽按钮
        private void button6_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX0.6", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.6"));
        }
        //拧紧枪1屏蔽按钮
        private void button7_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX0.7", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.7"));
        }
        //拧紧枪2屏蔽按钮
        private void button8_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.0", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX1.0"));
        }
        //返回原位按钮（大复位）
        private void button9_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.1", true);
        }

        private void button9_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.1", false);
        }
        //报警复位按钮
        private void button10_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.2", true);
        }

        private void button10_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.2", false);
        }
        //强制不合格按钮
        private void button13_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.5", true);
        }

        private void button13_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.5", false);
        }
        //相机拍照
        private void button17_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.7", true);
        }
        private void button17_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX1.7", false);
        }
        //防螺钉掉入屏蔽1
        private void button3_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX2.4", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.4"));
        }
        //防螺钉掉入屏蔽3
        private void button4_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX2.6", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.6"));
        }
        //防螺钉掉入屏蔽4
        private void button5_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX2.7", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.7"));
        }
        //防螺钉掉入屏蔽2
        private void button11_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX2.5", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.5"));
        }
        //通堵气缸2伸出
        private void button14_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX6.0", true);
        }

        private void button14_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX6.0", false);
        }
        //防错压紧气缸1压紧
        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX4.0", true);
        }

        private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX4.0", false);
        }
        //防错压紧气缸1松开
        private void button16_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX4.1", true);
        }

        private void button16_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX4.1", false);
        }
        //通堵气缸2缩回
        private void button15_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX6.1", true);
        }

        private void button15_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX6.1", false);
        }
        ////气压表开始检测 
        //private void button19_MouseDown(object sender, MouseEventArgs e)
        //{
        //    FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX8.0", true);
        //}
        //private void button19_MouseUp(object sender, MouseEventArgs e)
        //{
        //    FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX8.0", false);
        //}
        ////气压表停止检测 
        //private void button18_MouseDown(object sender, MouseEventArgs e)
        //{
        //    FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX8.1", true);
        //}
        //private void button18_MouseUp(object sender, MouseEventArgs e)
        //{
        //    FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX8.1", false);
        //}
        //压紧机构气缸伸出
        private void button21_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX10.0", true);
        }
        private void button21_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX10.0", false);
        }
        //压紧机构气缸缩回
        private void button20_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX10.1", true);
        }
        private void button20_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX10.1", false);
        }
        //状态
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.2"))
            {
                button2.BackColor = Color.Green;    //静音
            }
            else
            {
                button2.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.5"))
            {
                button12.BackColor = Color.Green;    //相机屏蔽按钮
            }
            else
            {
                button12.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX1.7"))
            {
                button17.BackColor = Color.Green;    //拍照按钮
            }
            else
            {
                button17.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.4"))
            {
                button3.BackColor = Color.Green;    //防螺钉掉入屏蔽1
            }
            else
            {
                button3.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.6"))
            {
                button4.BackColor = Color.Green;    //防螺钉掉入屏蔽3
            }
            else
            {
                button4.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.7"))
            {
                button5.BackColor = Color.Green;    //防螺钉掉入屏蔽4
            }
            else
            {
                button5.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.6"))
            {
                button6.BackColor = Color.Green;    //扫码屏蔽
            }
            else
            {
                button6.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX0.7"))
            {
                button7.BackColor = Color.Green;    //拧紧枪屏蔽1
            }
            else
            {
                button7.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX1.0"))
            {
                button8.BackColor = Color.Green;    //拧紧枪屏蔽2
            }
            else
            {
                button8.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX1.1"))
            {
                button9.BackColor = Color.Green;    //工件在原位（返回原位）
            }
            else
            {
                button9.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX1.2"))
            {
                button10.BackColor = Color.Green;   //复位
            }
            else
            {
                button10.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX2.5"))
            {
                button11.BackColor = Color.Green;   //防螺钉掉入屏蔽2
            }
            else
            {
                button11.BackColor = Color.Silver;
            }
            
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX1.5"))
            {
                button13.BackColor = Color.Green;   //强制不合格
            }
            else
            {
                button13.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX30.0"))
            {
                button14.BackColor = Color.Green;   //通堵气缸2伸出
            }
            else
            {
                button14.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX30.1"))
            {
                button15.BackColor = Color.Green;   //通堵气缸2缩回
            }
            else
            {
                button15.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX28.0"))
            {
                button1.BackColor = Color.Green;    //防错压紧气缸1伸出
            }
            else
            {
                button1.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX28.1"))
            {
                button16.BackColor = Color.Green;   //防错压紧气缸1缩回
            }
            else
            {
                button16.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX32.0"))
            {
                button19.BackColor = Color.Green;   //气压表开始检测
            }
            else
            {
                button19.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX32.0"))
            {
                button18.BackColor = Color.Green;   //气压表停止检测
            }
            else
            {
                button18.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX34.0"))
            {
                button21.BackColor = Color.Green;   //压紧机构气缸伸出
            }
            else
            {
                button21.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB1050.DBX34.1"))
            {
                button20.BackColor = Color.Green;   //压紧机构气缸缩回
            }
            else
            {
                button20.BackColor = Color.Silver;
            }
        }
        //气压表检测
        private void button19_Click(object sender, EventArgs e)
        {
            //FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX8.0", true);
            FormMain.PLC_Link[0].WriteBoolen("DB1050.DBX8.0", !FormMain.PLC_Link[0].readBoolen("DB1050.DBX8.0"));
        }
        
    }
}
